var mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/mern-starter');

var helloworld_users_Schema = mongoose.Schema({
  openID: String,
  XXopenID: String,
  unionID: String,
  attention: Boolean,
  name: String,
  sex: String,
  groups: [{
    group_id: String,
    name: String
  }],
  C_groups: [{
    group_id: String,
    name: String
  }]
});

var helloworld_users = mongoose.model(
  'helloworld_users',
  helloworld_users_Schema
);

var records_Schema = mongoose.Schema({
  openID: String,
  unionID: String,
  content: String,
  step: Number,
  stepAnswer: String,
  stepResult: String
});

var records = mongoose.model('helloworld_records', records_Schema);

var group_Schema = mongoose.Schema({
  openID: String,
  unionID: String,
  name: String,
  members: [{
    openID: String,
    XXopenID: String,
    unionID: String,
    name: String,
  }]
});

var groups = mongoose.model('helloworld_groups', group_Schema);


var group_message_Schema = mongoose.Schema({
  group_id: String,
  activity: String,
  name: String,
  host: String,
  time: String,
  place: String,
  comment: String
});

var group_messages = mongoose.model('helloworld_group_messages', group_message_Schema);

var feedback_message_Schema = mongoose.Schema({
  openid: String,
  unionid: String,
  content: String
});

var feedback_messages = mongoose.model('helloworld_feedback_messages', feedback_message_Schema);

module.exports = {
  helloworld_users: helloworld_users,
  records: records,
  groups: groups,
  group_messages: group_messages,
  feedback_messages: feedback_messages
};
